package com.pro.service.imple;

import com.pro.mapper.JsCarouselMapper;
import com.pro.pojo.JsCarousel;
import com.pro.service.JsCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * ClassName:jsCarouselServiceImple
 * Package:com.pro.service.imple
 * Description:  轮播图列表
 *
 * @Date:2021/11/12 下午 7:59
 * @Author: WYH
 */
@Service
public class JsCarouselServiceImple implements JsCarouselService {

    @Autowired(required = false)
    private JsCarouselMapper jsCarouselMapper;

    /**
     * @author WYH
     * @date 2021/11/12 下午 7:59
     * @content : 查询轮播图
     */
    @Override
    public List<JsCarousel> getAllBanner(String display,String imgType,Integer limit, Integer page) {
        page = (page-1)*limit;
        List<JsCarousel> allBanner = jsCarouselMapper.getAllBanner(display,imgType,limit, page);
        return allBanner;
    }
    /**
     * @author WYH
     * @date 2021/11/14 下午 7:58
     * @content : 查看单个轮播对象
     */
    @Override
    public JsCarousel getBanner(Integer carouselId) {
        JsCarousel banner = jsCarouselMapper.getBanner(carouselId);
        return banner;
    }
    /**
     * @author WYH
     * @date 2021/11/15 上午 11:49
     * @content : 计算总个数
     */
    @Override
    public int count(String display,String imgType){
        int count = jsCarouselMapper.count(display, imgType);
        return count;
    }
    /**
     * @author WYH
     * @date 2021/11/15 上午 9:28
     * @content : 编辑轮播图
     */
    @Override
    public Boolean updateBanner(JsCarousel jsCarousel) {
        jsCarousel.setUpdateDate(new Date());
        Boolean aBoolean = jsCarouselMapper.updateBanner(jsCarousel);
        return aBoolean;
    }

    /**
     * @author WYH
     * @date 2021/11/15 下午 3:09
     * @content : 添加轮播图
     */
    @Override
    public Boolean addBanner(JsCarousel jsCarousel){
        Boolean aBoolean = jsCarouselMapper.addBanner(jsCarousel);
        return aBoolean;
    }

    /**
     * @author WYH
     * @date 2021/11/15 下午 8:27
     * @content : 删除轮播图
     */
    @Override
    public Boolean delBanner(Integer carouselId){
        Boolean aBoolean = jsCarouselMapper.delBanner(carouselId);
        return aBoolean;
    }
    /**
     *
     * @author ZPT
     * @date 2021/12/7 20:04
     * @content :到期量
     */
    @Override
    public int expireCount() {
        return jsCarouselMapper.expireCount();
    }
}
